package com.nagat.http.xml;

import java.io.StringReader;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

/**
 * @author yasenagat  E-mail: yasenagat@163.com
 * @version 创建时间：2012-4-5 下午3:19:29
 * 类说明
 */
public class DomHelp {

	
	
	
	
	public static void main(String[] args) {
		
		try {
			String xml = "<?xml version='1.0' encoding='utf-8'?>" +
					"<message>" +
					"<head>" +
					"<version>1000</version>" +
					"<command>1001</command>" +
					"</head><body>1" +
					"</body>" +
					"</message>";
			
			SAXReader saxReader = new SAXReader();
			StringReader read = new StringReader(xml);
			Document  document = saxReader.read(read);

			Element rootElm = document.getRootElement();
			
			Element memberElm = rootElm.element("body");
			
			String body = memberElm.getText();
			System.out.println(body);
		} catch (DocumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
